//package com.tinshow.web.httpclient;
//
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONArray;
//import com.alibaba.fastjson.JSONObject;
//import org.apache.commons.httpclient.HostConfiguration;
//import org.apache.http.HttpResponse;
//import org.apache.http.NameValuePair;
//import org.apache.http.client.HttpClient;
//import org.apache.http.client.entity.UrlEncodedFormEntity;
//import org.apache.http.client.methods.HttpPost;
//import org.apache.http.impl.client.DefaultHttpClient;
//import org.apache.http.message.BasicNameValuePair;
//import org.apache.http.protocol.HTTP;
//import org.apache.http.util.EntityUtils;
//import org.apache.log4j.Logger;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Created by randy on 16-12-10.
// */
//public class Huipinzhe {
//
//    private static final Logger logger = Logger.getLogger(Huipinzhe.class);
//
//    private static String[] cate = {"女装","男装","母婴","鞋包","居家","配饰","美食","数码","美妆","文体"};
//
////    public static void main(String[] args){
//////        System.out.print(getLogin());
////        getLogin();
////    }
//
//    public static String getLogin(){
//        try {
//            HttpClient client =  new DefaultHttpClient();
//            HostConfiguration host = new HostConfiguration();
//            HttpPost post = new HttpPost("http://sj2.huipinzhe.com/login/login");
//            post.setHeader("Accept","\t\n" +
//                    "application/json, text/javascript, */*; q=0.01");
//            post.setHeader("Content_type","application/x-www-form-urlencoded; charset=UTF-8");
//            post.setHeader("Referer","http://sj2.huipinzhe.com/login.html");
//            post.setHeader("User-Agent","Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0");
//            List<NameValuePair> list = new ArrayList<NameValuePair>();
//            list.add(new BasicNameValuePair("cellphone","18629535101"));
//            list.add(new BasicNameValuePair("password","848er848"));
//            post.setEntity(new UrlEncodedFormEntity(list, HTTP.UTF_8));
//            HttpResponse response = client.execute(post);
//            String result = "";
//            if(response.getStatusLine().getStatusCode() == 200){
//                result = EntityUtils.toString(response.getEntity(),"UTF-8");
//                util(client);
//                return result;
//            }
//        }catch (Exception e){
//            e.printStackTrace();;
//        }
//        return null;
//    }
//
//    public static String getCate(HttpClient httpClient,String id,String name){
//        try{
//            HttpPost post = new HttpPost("http://sj2.huipinzhe.com/merchant/category/getCategoriesByPid");
//            post.setHeader("Accept","application/json, text/javascript, */*; q=0.01");
//            post.setHeader("Accept-Encoding","gzip, deflate");
//            post.setHeader("Connection","keep-alive");
//            post.setHeader("Origin","http://sj2.huipinzhe.com");
//            post.setHeader("Referer","http://sj2.huipinzhe.com/m-apply.html?typeId=17");
//            post.setHeader("User-Agent","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36");
//            List<NameValuePair> list = new ArrayList<NameValuePair>();
//            list.add(new BasicNameValuePair("pid",id));
//            post.setEntity(new UrlEncodedFormEntity(list,HTTP.UTF_8));
//            HttpResponse response = httpClient.execute(post);
//            String result = "";
//            if(response.getStatusLine().getStatusCode() == 200){
//                result = EntityUtils.toString(response.getEntity(),"UTF-8");
////                System.out.print(result);
//                parseJson(result,name);
//                return result;
//            }
//        }catch(Exception e) {
//            e.printStackTrace();
//        }
//
//        return "";
//    }
//
//    public static String util(HttpClient httpClient){
//        for (int i = 1;i <= cate.length;i++){
//            getCate(httpClient,String.valueOf(i),cate[i-1]);
//        }
//        return "";
//    }
//
//    public static String parseJson(String json,String name){
//        JSONObject jsonObject = JSON.parseObject(json);
//        JSONArray jsonArray = jsonObject.getJSONArray("data");
//        for(int i  =0; i< jsonArray.size();i++){
//            JSONObject jsonObject1 = (JSONObject)jsonArray.get(i);
//            String id = jsonObject1.getString("id");
//            String categoryName = jsonObject1.getString("categoryName");
//            String parentId = jsonObject1.getString("parentId");
//
//            System.out.print(name+"====="+id+"~"+categoryName+"~"+parentId+"\n");
//        }
//        return "";
//    }
//
//
//}
